﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TouchControll : MonoBehaviour {

	void Start () {
		if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) {
			transform.GetChild (0).gameObject.SetActive (true);
			transform.GetChild (1).gameObject.SetActive (true);
		}
	}
	
	void Update () {
		
	}

	public void Move(Vector2 move){
		var player = GameObject.Find ("Player").GetComponent<PlayerCtrl> ();
		if (move.x < 0) {
			player.leftDown = true;
		} else if(move.x > 0){
			player.rightDown = true;
		}
	}

	public void Press(){
		var player = GameObject.Find ("Player").GetComponent<PlayerCtrl> ();
		if (player.grounded) {
			player.preJump ();
		} else {
			if (player.hasFirstTouch) {
				if (!player.jumpSec) {
					player.secondJump ();
				}
			}
		}

	}
}
